<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<shiro:hasPermission name="coupon:select">
	<div class="content1">
		<div class="header">
			<h1 class="page-title">免息劵发放列表</h1>
			<ul class="breadcrumb">
				<li>用户管理</li>
				<li class="active">免息劵发放列表</li>
			</ul>
		</div>
		<div class="main-content">
			<div class="row">
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group"> 
							<div class="input-group-addon">状态说明</div>
							<select class="form-control" id="state">
								<option value="">--请选择--</option>
								<option value="1">未使用</option>
								<option value="2">已使用</option>
								<option value="3">过期</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<div class="form-group">
						<div class="input-group">
							<div class="input-group-addon">渠道</div>
							<select class="form-control" id="source">
								<option value="">--请选择--</option>
								<option value="0">系统赠送</option>
								<option value="1">邀请赠送</option>
								<option value="2">分享赠送</option>
								<option value="3">其他活动</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-md-2">
					<button type="button" class="btn btn-primary btn-small btn-block"
						id="query">
						<i class="glyphicon glyphicon-search"></i> 查询
					</button>
				</div>
			</div>
			<table id="example" class="table"></table>
		</div>
		<script>
			//表格的初始化
			$(document).ready(function() {
				var table = $('#example').initTable({
					sAjaxSource:"coupon/initTable.htm",
					aoColumns: [
			            { 
				              "data": "couponDays",
				              "sTitle":"天数",
				              'sClass':"text-center"
				            },
				            { 
					              "data": "useId",
					              "sTitle":"使用编号",
					              'sClass':"text-center"
					            },
			            { 
			                "data": "state",
			                "sTitle":"状态说明",
			                'sClass':"text-center",
			                "mRender": function(data, type, full) { 
			                	if(data == 1){
									return "<font color='red'>未使用</font>";
								}else if(data == 2){
									return "<font color='red'>已使用</font>";
								}else if(data == 3){
									return "<font color='red'>过期</font>";
								}
			                } 
			            },
			            { 
			                "data": "source",
			                "sTitle":"来源",
			                'sClass':"text-center",
			                "mRender": function(data, type, full) { 
			                	if(data == 0){
									return "<font color='red'>系统赠送</font>";
								}else if(data == 1){
									return "<font color='red'>邀请赠送</font>";
								}else if(data == 2){
									return "<font color='red'>分享赠送</font>";
								}else if(data == 3){
									return "<font color='red'>其他活动</font>";
								}else{
									return "<font color='red'>暂未结果</font>";
								}
			                } 
			            },
			            { 
			            	"data": "createMan",
			            	"sTitle":"创建人",
			            	'sClass':"text-center"
			            },
			            { 
			            	"data": "modifyMan",
			            	"sTitle":"修改人",
			            	'sClass':"text-center"
			            },
			            { 
			                "data": "remark",
			                "sTitle":"备注",
			                'sClass':"text-center"
			            },
			            { 
			                "data": "beginTime",
			                "sTitle":"开始时间",
			                'sClass':"text-center"
			            },
			            { 
			                "data": "endTime",
			                "sTitle":"结束时间",
			                'sClass':"text-center"
			            },
			         ],
					 fnServerParams: function (aoData) {  //查询条件
		             	aoData.push({ "name": "state", "value": $("#state").val() } );
		             	aoData.push({ "name": "source", "value": $("#source").val() } );
		             },
		             aoColumnDefs : [
						<shiro:hasPermission name="coupon:update or coupon:delete">
		             	{"aTargets" :9,"mRender" : function(data, type, row){
		             		var edit="",del="";
		                    return edit+"&nbsp;"+del;
		                }
		             }
		            	</shiro:hasPermission>
		             ]
				});
				
				 $('#query').click(function(){
					$('#example').dataTable().fnDraw();
				});
			
			});
			//删除受影响的行数
			function deleteRow(id){
				console.log(id);
				$('#myModal').deleteRow('coupon/del.htm?id='+id);
			}
			//增加或者修改受影响的行数
			function addAndUpdateRow(id){
				$('#insertAndUpdate').addAndUpdateRow("coupon/addAndUpdateHome.htm?id="+id);
			}
			</script>
		<!---dialog选项-->
		<div>
			<jsp:include page="/WEB-INF/views/common/delete_dialog.jsp" />
			<jsp:include page="/WEB-INF/views/common/addupdate_dialog.jsp" />

			<div class="modal fade" id="insertAndUpdate" tabindex="-1"
				role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			</div>
		</div>
	</div>
</shiro:hasPermission>